package org.xx.armory.swing.builders;

import java.util.ArrayList;
import java.util.List;

public class TextModelBuilder
        extends ComponentModelBuilder<TextModel>
        implements OptionsContainerBuilder {
    private TextModelType type;
    private int size;
    private int rowSize;
    private boolean required;
    private int maxLength;
    private String minValue;
    private String maxValue;
    private String pattern;
    private String prefix;
    private String suffix;
    private String optionsName;
    private List<OptionModel> options;

    public TextModelBuilder() {
        this.options = new ArrayList<>();
    }

    public final TextModelBuilder setType(
            TextModelType type
    ) {
        this.type = type;
        return this;
    }

    public final TextModelBuilder setSize(
            int size
    ) {
        this.size = size;
        return this;
    }

    public final TextModelBuilder setRowSize(
            int rowSize
    ) {
        this.rowSize = rowSize;
        return this;
    }

    public final TextModelBuilder setRequired(
            boolean required
    ) {
        this.required = required;
        return this;
    }

    public final TextModelBuilder setMaxLength(
            int maxLength
    ) {
        this.maxLength = maxLength;
        return this;
    }

    public final TextModelBuilder setMinValue(
            String minValue
    ) {
        this.minValue = minValue;
        return this;
    }

    public final TextModelBuilder setMaxValue(
            String maxValue
    ) {
        this.maxValue = maxValue;
        return this;
    }

    public final TextModelBuilder setPattern(
            String pattern
    ) {
        this.pattern = pattern;
        return this;
    }

    public final TextModelBuilder setPrefix(
            String prefix
    ) {
        this.prefix = prefix;
        return this;
    }

    public final TextModelBuilder setSuffix(
            String suffix
    ) {
        this.suffix = suffix;
        return this;
    }

    public final TextModelBuilder setOptionsName(
            String optionsName
    ) {
        this.optionsName = optionsName;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final void addOption(
            OptionModel option
    ) {
        this.options.add(option);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public TextModel build() {
        return new TextModel(getLineInfo(), getName(), isVisible(), this.type, this.size, this.rowSize, this.required,
                             this.maxLength, this.minValue, this.maxValue, this.pattern,
                             this.optionsName, this.prefix, this.suffix, this.options);
    }
}
